package com.ganzalang.gmall.designpatterns.prototype;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @description: 不使用原型模式
 * @author: ganzalang
 */
public class WithoutPrototypePatternDemo {
    public static void main(String[] args) {
        Product product = new Product("产品", new Component("组件"));
        //浅拷贝,componet组件的引用没变
        Product copyProduct = new Product(product.getName(), product.getComponent());

    }



    @Data
    @AllArgsConstructor
    public static class Component{
        private String name;
    }

    @Data
    @AllArgsConstructor
    public static class Product{
        private String name;
        private Component component;



        @Override
        protected Object clone() throws CloneNotSupportedException {
            return super.clone();
        }
    }
}
